package com.mdlib.helper.ui.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ljlib.core.util.common.TimeUtils;
import com.ljlib.help.R;
import com.mdlib.helper.model.entity.MessageEntity;

import java.util.List;

/**
 * 作者：HQY on 16/11/18 14:24
 * 邮箱：hqy_xz@126.com
 */

public class SendMessageAdapter extends BaseQuickAdapter<MessageEntity> {

    public SendMessageAdapter(List<MessageEntity> data) {
        super(R.layout.item_send_message, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, MessageEntity messageEntity) {

        baseViewHolder.setText(R.id.tv_message_title, messageEntity.getContent())
                .setText(R.id.tv_message_time, TimeUtils.milliseconds2String(Long.valueOf(messageEntity.getCreated_at())*1000, TimeUtils.SUCCESS_MONTH));

        if (messageEntity.getType() == 1) {
            Glide.with(mContext)
                    .load(R.drawable.iv_message_order)
                    .placeholder(R.drawable.iv_message_order)
                    .error(R.drawable.iv_message_order)
                    .into((ImageView) baseViewHolder.getView(R.id.iv_message_pic));
        }

    }
}
